package controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import po.ResourceStrategy;
import po.Result;
import service.ResourceStrategyService;

import java.util.List;

@Controller
@RequestMapping("/resourceStrategy")
public class ResourceStrategyController {
    @Autowired
    private ResourceStrategyService resourceStrategyService;

    @RequestMapping("/getResourceStrategyView")
    public String getResourceStrategyView() {
        return "strategy/resourceStrategy";
    }

    @RequestMapping("/findAllResourceStrategies")
    public @ResponseBody
    List<ResourceStrategy> findAllResourceStrategies() throws Exception {
        return resourceStrategyService.findAllResourceStrategies();
    }

    @RequestMapping("/getAddResourceStrategyView")
    public String getAddResourceStrategyView() {
        return "strategy/addResourceStrategy";
    }

    @RequestMapping("/addResourceStrategy")
    public @ResponseBody
    Result addResourceStrategy(ResourceStrategy resourceStrategy) {
        return resourceStrategyService.addResourceStrategy(resourceStrategy);
    }

    @RequestMapping("/deleteResourceStrategyById")
    public @ResponseBody
    Result deleteResourceStrategyById(int id) {
        return resourceStrategyService.deleteResourceStrategyById(id);
    }

    @RequestMapping("/findResourceIdForComb")
    public @ResponseBody
    List<Object> findResourceIdForComb(String type) throws Exception {
        return null;
    }

    @RequestMapping("/getEditResourceStrategyView")
    public String getEditResourceStrategyView() {
        return "strategy/editResourceStrategy";
    }

    @RequestMapping("/updateResourceStrategy")
    public @ResponseBody
    Result updateResourceStrategy(ResourceStrategy resourceStrategy) {
        return resourceStrategyService.updateResourceStrategyById(resourceStrategy.getId(), resourceStrategy);
    }
}
